﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
using System.Data.Common;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data;


public abstract class BaseNode:IComparable
{
    protected XmlNode _xmlNode;
    protected XmlDocument _xmlDoc;
    public BaseNode(XmlNode Node)
    {
        _xmlNode = Node;
        _xmlDoc = _xmlNode.OwnerDocument;
    }

    public XmlNode Node
    {
        get
        {
            return _xmlNode;
        }
    }

    public virtual int No
    {
        get
        {
            return int.Parse(_xmlNode.Attributes["NO"].Value);
        }
        set
        {
            _xmlNode.Attributes["NO"].Value = value.ToString();
        }
    }

    public virtual string Name
    {
        get
        {
            return _xmlNode["Name"].InnerText;
        }
        set
        {
            _xmlNode["Name"].InnerText = value.ToString();
        }
    }

    //public virtual void ImportNode(XmlNode tar)
    //{
    //    if (tar == null) return;
    //    if (_xmlNode == null) return;

    //    //delete old node
    //    XmlDocument doc = _xmlNode.OwnerDocument;

    //    //insert new node
    //    XmlNode pNode = _xmlNode.ParentNode;
    //    if (pNode == null) return;

    //    pNode.AppendChild(tar);

    //    //pNode.InsertAfter(_xmlNode, tar);

    //    //delete old node
    //    pNode.RemoveChild(_xmlNode);

    //    //return false;
    //    _xmlNode = tar;

    //}


    public int CompareTo(object obj)
    {
        if (obj is BaseNode)
        {
            BaseNode temp = obj as BaseNode;
            return this.No.CompareTo(temp.No);
        }
        throw new NotImplementedException("对象不匹配！");
    }



}